﻿using System;
using System.Windows.Navigation;

// This file contains Windows Phone 8 utility routines. The code is licensed with the Microsoft Public License (Ms-PL).
// Both commercial and non-commercial usage is allowed, free of charge.
// Original source: https://phoneandstoreapphelpers.codeplex.com/
// Code by Jani Järvinen, Finland. Copyright © 2013–2014.

namespace JaniJarvinen
{
    public static class PhoneUtilities
    {
        /// <summary>
        /// Navigates to the given XAML page by giving only the page's name without more difficult relative URLs. This method extends the built-in NavigationService class so that you can simply navigate to a new page by saying, 'NavigationService.NavigateToPage("My");'.
        /// </summary>
        /// <example>Call this method with the page parameter of "My", and you will navigate to the URL "/MyPage.xaml". The "Page.xaml" part will be automatically appended.</example>
        /// <param name="service">The (implied) instance of the NavigationService class from the built-in System.Windows.Navigation namespace.</param>
        /// <param name="page">Name of the page to navigate to, without any beginning path or the "Page.xaml" extension.</param>
        public static void NavigateToPage(this NavigationService service, string page)
        {
            service.Navigate(new Uri("/" + page + "Page.xaml", UriKind.Relative));
        }
    }
}
